var fade,dir,fmin,fmax,fspeed;

function fader(fn,fx,fs){
  fmin=fn;
  fmax=fx;
  fspeed=fs;
  fade=fmin;
  dir=1;
  t=setInterval('dofade();',200);
}

function dofade(){
  if(dir==1){
    if(fade<fmax-fspeed){fade+=fspeed;}
    else{fade=fmax;dir=0;}
  }
  else{
    if(fade>fmin+fspeed){fade-=fspeed;}
    else{fade=fmin;dir=1;}
  }
  var hfade=d2h(fade);
  if(hfade.length<2){hfade='0'+hfade;}
  document.bgColor='#'+hfade+'0000';
}